import { request } from './index'

// 获得table数据
export function GetRoleFnc () { 
  return request({
    url: '/roles',
    method: 'get'
  })
}

// 删除展开行下的数据
export function DeleteRoleChildrenFnc (roleID: number, rightID: number) {
  return request({
    url: `/roles/${roleID}/rights/${rightID}`,
    method: 'delete'
  })
}

// 展示编辑角色盒子
export function ShowRoleFnc (id: number, data: {roleId: number, roleName: string, roleDesc: string}) { 
  return request({
    url: `/roles/${id}`,
    method: 'get',
    data: data
  })
}

// 修改角色
export function EditRoleFnc (id: number, data: any) { 
  return request({
    url: `/roles/${id}`,
    data: data,
    method: 'put'
  })
}

// 展示权限分配盒子
export function ShowRightFnc () { 
  return request({
    url: '/rights/tree',
    method: 'get'
  })
}

// 更新权限分配
export function SetRightFnc (id: number, data: {rids: string}) { 
  return request({
    url: `/roles/${id}/rights`,
    method: 'post',
    data: data
  })
}